package com.clkj.xiuzheng.dao.shangcheng;

import com.clkj.xiuzheng.pojo.shangcheng.CollectOrPrise;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author yawang
 * @create 2024/05/20 10:45:42
 **/
@Repository
public interface CollectOrPriseMapper extends Mapper<CollectOrPrise> {

    @Select("select collect_flag  from t_xz_collectOrPrise where product_id = #{baiKeId} and user_id = #{userId} and  collect_type in (1,2) group by  collect_flag")
    List<CollectOrPrise> listCollect(Integer userId, Integer baiKeId);

    @Select("select a.* ,b.product_name,b.product_image,c.baike_title,c.baike_img,c.baike_content  from t_xz_collectOrPrise a left join t_xz_product b on a.product_id = b.product_id and a.collect_type = 0 " +
            "left join t_xz_topicOrVideo c on a.product_id = c.baike_id and a.collect_type in( 1,2) " +
            "where a.user_id = #{userId} and a.collect_flag = 1")
    List<CollectOrPrise> listCollectByUser(@Param("userId")Integer userId);
}
